package org.biloxi.commands.playcard;

import org.biloxi.commands.CommandRepository;
import org.biloxi.commands.impl.CommandImpl;
import org.biloxi.commands.movecard.MoveCard;
import org.biloxi.model.magicobjects.MagicObject;
import org.biloxi.model.mutable.GameStateMutable;
import org.biloxi.model.player.PlayerState;
import org.biloxi.model.player.Zone;
import org.biloxi.player.PlayerID;

public class PlayCard extends CommandImpl<PlayCard.Options, PlayCard.Result> {
	
	public static class Options {
		public final PlayerID pid;
		public final MagicObject card;
		public Options(PlayerID pid, MagicObject card) {
			this.pid = pid;
			this.card = card;
		}
	}
	
	public static class Result {
		public final PlayerID pid;
		public final Zone source;
		public final MagicObject card;
		public Result(PlayerID pid, Zone source, MagicObject card) {
			this.pid = pid;
			this.source = source;
			this.card = card;
		}
	}

	public PlayCard(CommandRepository cr) {
		super(cr);
	}

	@Override
	protected Result executeImpl(Options o, GameStateMutable gameState) {
		PlayerState player = gameState.getPlayerState(o.pid);
		MagicObject card = player.getHand().getMagicObjects().get(0);
		MoveCard.Result tmpResult = c.moveCard( new MoveCard.Options(player.getHand(),player.getInPlay(),card) );
		return new Result(tmpResult.dest.getOwnerid(),tmpResult.source,tmpResult.card);
	}
};
